package edu.java.texbooks.scjp.threads.test16;

/**
 * 
 * Test what will happen if current thread calls join() method to itself.
 * 
 */
public class Test {
	public static void main(String[] args) {
		System.out.println(Thread.currentThread().getName()
				+ " thread starts...");

		System.out.println("Main thread starts to join itself.");
		try {
			// deadlock
			// Thread.currentThread().join();

			// not deadlock
			Thread.currentThread().join(5000);
		} catch (InterruptedException e) {
			System.out.println("Interrupted Exception in main thread.");
		}

		System.out.println("Main thread prints something after join() method.");
	}
}
